<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.*,
						com.ophelisis.common.util.*,
						com.ophelisis.common.consts.*,
						com.ophelisis.actions.system.*"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<script>
$(document).ready(function() {
	$("#searchForm").find("input[type=text]").attr("disabled","disabled");
	$("#searchForm").find("input[type=password]").attr("disabled","disabled");
	$("#searchForm").find("input[type=radio]").attr("disabled","disabled");
	$("#searchForm").find("input[type=file]").hide();
	$("#searchForm").find("select").attr("disabled","disabled");
	$("#searchForm").find("textarea").attr("disabled","disabled");
	$(".btnModify").show();
	$(".btnSave").hide();
	
	if ($("#_delYn").val() == "Y") {
		$(".btnModify, .btnSave").hide();
		$("#btnList").show();
		$("#btnDelete").show();
	}
	
	if (checkUserAuth() < 2) {
		$(".btnModify, .btnSave").hide();
		$("#btnList2").show();
	}
	
	if ($("#categoryFirst option").length < 2) {
		$("#categoryFirst").parent().parent().remove();
	} else {
		if ($("#categorySecond option").length < 2) {
			$("#categorySecond").remove();
			$("#categoryThird").remove();
		} else {
			if ($("#categoryThird option").length < 2) {
				$("#categoryThird").remove();
			}
		}
	}
});
</script>
<%@ include file="/WEB-INF/jsp/common/resultMessageLocal.jsp"%>
<div id="formlist1" class="noborder">
	<input type="hidden" id="loadCheck" name="loadCheck" value="OK" />
	<form id="searchForm" name="searchForm" method="post" enctype="multipart/form-data">
    	<input type="hidden" id="searchVal1" name="searchVal1" value="${searchVal1}" />
    	<input type="hidden" id="isNew" name="isNew" value="N" />
    	<input type="hidden" id="isFileCheck" name="isFileCheck" value="" />
		<table class="viewstyle1">
			<c:choose>
				<c:when test="${boardList != '' && !empty boardList}">
					<c:forEach var="list" items="${boardList}" varStatus="status">
				    	<input type="hidden" id="boardId" name="boardId" value="${list.boardId}" />
    					<input type="hidden" id="categoryId" name="categoryId" value="${list.categoryId}" />
						<colgroup>
							<col width="130" />
							<col width="" />
						</colgroup>
						<tr>
							<td class="titleColumn" colspan="2">기본 정보</td>
						</tr>
						<tr>
							<th scope="col">제목</th>
							<td scope="col"><input type="text" id="boardNm" name="boardNm" class="in3 intex_l width_700p" value="${list.boardNm}" /></td>
						</tr>
						<tr>
							<th scope="col">카테고리</th>
							<td scope="col">
							<select id="categoryFirst" name="categoryFirst" class="in3 intex_l" onchange="javascript:pmModule.selectCategory('1', this.value);">
								<option value="">== 1차 카테고리 ==</option>
								<c:choose>
									<c:when test="${categoryList != '' && !empty categoryList}">
										<c:forEach var="cfList" items="${categoryList}" varStatus="status">
											<c:if test="${cfList.categoryType == '1'}">
												<option value="${cfList.categoryId}" <c:if test="${list.categoryId == cfList.categoryId || list.categoryFirst == cfList.categoryId}">selected="selected"</c:if>>${cfList.categoryNm}</option>
											</c:if>
										</c:forEach>
									</c:when>
								</c:choose>
							</select>
							<select id="categorySecond" name="categorySecond" class="in3 intex_l" onchange="javascript:pmModule.selectCategory('2', this.value);">
								<option value="">== 2차 카테고리 ==</option>
								<c:choose>
									<c:when test="${categoryList != '' && !empty categoryList}">
										<c:forEach var="csList" items="${categoryList}" varStatus="status">
											<c:if test="${csList.categoryType == '2'}">
												<option value="${csList.categoryId}" first="${csList.categoryFirst}" <c:if test="${list.categoryId == csList.categoryId || list.categorySecond == csList.categoryId}">selected="selected"</c:if>>${csList.categoryNm}</option>
											</c:if>
										</c:forEach>
									</c:when>
								</c:choose>
							</select>
							<select id="categoryThird" name="categoryThird" class="in3 intex_l" onchange="javascript:pmModule.selectCategory('3', this.value);">
								<option value="">== 3차 카테고리 ==</option>
								<c:choose>
									<c:when test="${categoryList != '' && !empty categoryList}">
										<c:forEach var="ctList" items="${categoryList}" varStatus="status">
											<c:if test="${ctList.categoryType == '3'}">
												<option value="${ctList.categoryId}" first="${ctList.categoryFirst}" second="${ctList.categorySecond}" <c:if test="${list.categoryId == ctList.categoryId}">selected="selected"</c:if>>${ctList.categoryNm}</option>
											</c:if>
										</c:forEach>
									</c:when>
								</c:choose>
							</select>
							</td>
						</tr>
						<tr>
							<th>내용</th>
							<td>
							<textarea id="boardDesc" name="boardDesc" class="width_700p height_250p">${list.boardDesc}</textarea>
							</td>
						</tr>
						<tr>
							<th></th>
							<td><span class="red pdl5">파일 크기는 5MB 이하를 권장합니다.(이미지 파일의 경우 너무 크면 로딩시간이 길어집니다.)</span></td>
						</tr>
						<c:set var="fileOldArray" value="${fn:split(list.boardFileOld, '|')}" />
						<c:set var="fileNewArray" value="${fn:split(list.boardFileNew, '|')}" />
						<c:set var="fileWidthArray" value="${fn:split(list.boardFileWidth, '|')}" />
						<tr>
							<th>첨부 파일 #1</th>
				            <td>
				            <input type="file" id="boardFile1" name="boardFile1" class="input_text" />
				            <input type="hidden" id="boardFileOld1" name="boardFileOld1" value="${fileOldArray[0]}" />
				            <input type="hidden" id="boardFileNew1" name="boardFileNew1" value="${fileNewArray[0]}" />
				            <div class="fileDiv">
								<a href="boardPdsFileDownload.action?fileName=${fileNewArray[0]}" target="iframeProcess">${fileOldArray[0]}</a>
							</div>
				            </td>
						</tr>
						<tr>
							<th>첨부 파일 #2</th>
				            <td>
				            <input type="file" id="boardFile2" name="boardFile2" class="input_text" />
				            <input type="hidden" id="boardFileOld2" name="boardFileOld2" value="${fileOldArray[1]}" />
				            <input type="hidden" id="boardFileNew2" name="boardFileNew2" value="${fileNewArray[1]}" />
				            <div class="fileDiv">
								<a href="boardPdsFileDownload.action?fileName=${fileNewArray[1]}" target="iframeProcess">${fileOldArray[1]}</a>
							</div>
				            </td>
						</tr>
					</c:forEach>
				</c:when>
			</c:choose>
		</table>
	</form>
	<div id="lowbtn">
		<a href="javascript:pmModule.setDelete();" id="btnDelete" class="btnModify"><img src="images/btn/btn_delete01.gif" /></a> 
		<a href="javascript:pmModule.setModify();" class="btnModify"><img src="images/btn/btn_modify01.gif" /></a> 
		<a href="javascript:pmModule.getList();" id="btnList" class="btnModify"><img src="images/btn/btn_list01.gif" /></a>
		
		<a href="javascript:pmModule.reset('reset');" class="btnSave"><img src="images/btn/btn_cancel01.gif" /></a>
		<a href="javascript:pmModule.save();" class="btnSave"><img src="images/btn/btn_save01.gif" /></a>  
		<a href="javascript:pmModule.getList('reset');" id="btnList2" class="btnSave"><img src="images/btn/btn_list01.gif" /></a>
	</div>
</div>
